#pragma once

#include "Animation.h"
#include <vector>
using namespace std;

#include "GameObject.h"
#include "Events\IListener.h"
#include "ToolManager.h"
#include "TinyXMLDan.h"
#include "GrapplingArm.h"
#include "LevelCompleteState.h"
#include "../HUD.h"

class Arm;
class HUD;

class Player : public GameObject, public IListener
{
	float velX;
	float velY;
	float walkSpeed;
	float curTime;
	float RepairAnimationTimer;
	float DeathAnimationTimer;
	float ImmuneTimer;

	int widthSolid;
	int heightSolid;

	//Animations
	Animation * ActiveAnimation;

	Animation IdolAnim;
	Animation RunningAnim;
	Animation RepairAnim;
	Animation DeathAnim;

	tVector2D heading;

	HUD* hud;

	ToolManager* toolManager;
	bool isDead;
	bool isOver;
	bool areControlsLocked;
	bool Immune;

	Arm* frontArm;
	Arm* RearArm;

	GrappleDirection grappleddir;

	//true if on ground
	bool isGrounded;
	float groundedDelay;
	//Controls moveleft/right
	bool canMoveLeft;
	bool canMoveRight;
	bool canMoveUp;
	bool canMoveDown;
	bool RepairAnimationPlaying;
	bool DeathAnimationPlaying;
	bool AnimationFacingLeft;


public:
	Player(void);
	virtual ~Player(void);

	//Overrides
	virtual void Update(float deltaTime)								override;
	virtual void Render(void) const										override;
	void HandleCollision( GameObject& colliding, CollisionInfo& other)	override;
	void SetHitBox(RECT hitBox)											override;

	void SetCheckPointData()											override;
	void ResetToCheckPoint()											override;

	void DeactivateMovement(void);
	void ActivateMovement(void);

	//////////////////////////////////////////////////
	// Accessors:
	bool GetIsGrounded( void ) { return isGrounded; }
	Animation* GetAnimation( void ) { return ActiveAnimation; }
	Arm* GetFrontArm( void ) { return frontArm; }
	Arm* GetRearArm( void ) { return RearArm; }

	//////////////////////////////////////////////////
	// Mutators:

	// Author: Joshua Bramer
	// Description:
	//		- Tells the player to deactivate the Grapple Arm and the Thermo.
	// Parameters:
	//		deactivate	-	Whether or not to deactivate the tools.
	void DeactivateToolsFromRadiation(bool deactivate);

	tVector2D GetHeading() const {return heading;}
	void SetHeading(tVector2D tempHeading) {heading = tempHeading;}

	void HandleInput(float deltaTime);

	ToolManager* GetToolManager() {return toolManager;}

	bool GetIsOver() const {return isOver;}
	void SetIsOver(bool over) {isOver = over;}

	float GetCurTime() const {return curTime;}
	void SetCurTime(float f) {curTime = f;}

	void SetLocked( bool locked ) { areControlsLocked = locked; }
	void SetDir( GrappleDirection dir ) { grappleddir = dir; }

	void HandleEvent(Event* pEvent)	override;

	void ChangeAnimation(Animation &switchto );
	float GetDeathTimer() {return DeathAnimationTimer;};
};